package com.smedi.ismedi.constructionproject.api.feign;

import com.smedi.ismedi.constructionproject.api.dto.request.BatchExistingPersonRequest;
import com.smedi.ismedi.constructionproject.api.dto.request.ProjectAssignmentEditRequest;
import com.smedi.ismedi.constructionproject.api.dto.request.ProjectAssignmentListQueryRequest;
import com.smedi.ismedi.constructionproject.api.dto.request.ProjectAssignmentRequest;
import com.smedi.ismedi.constructionproject.api.dto.response.ProjectAssignmentResponse;
import com.smedi.ismedi.constructionproject.api.dto.response.resp.ProjectAssignmentForMobileResp;
import com.smedi.ismedi.constructionproject.api.dto.response.resp.ProjectAssignmentResp;
import com.smedi.ismedi.web.starter.common.PaginationData;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Api(tags = {"项目分配接口"})
@FeignClient(name = "ismedi-construction-project")
@RequestMapping(value = "/api/v1/construction-project/assignment")
public interface RemoteProjectAssignmentFeignApi {
    /**
     * 保存项目分配信息
     *
     * @param
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "保存项目分配信息")
    @PostMapping(value = "/save")
    ResponseData<ProjectAssignmentResponse> postSave(@Validated @RequestBody ProjectAssignmentRequest projectAssignmentRequest);

    /**
     * 编辑 项目分配
     *
     * @param
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "编辑 项目分配")
    @PostMapping(value = "/edit")
    ResponseData<Boolean> editProjectAssignment(@Validated @RequestBody ProjectAssignmentEditRequest projectAssignmentEditRequest);

    /**
     * 批量保存已存在人员
     *
     * @param batchExistingPersonRequest
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "批量保存已存在人员")
    @PostMapping(value = "/batchAddExistingPerson")
    ResponseData<Boolean> postBatchAddExistingPerson(@Validated @RequestBody BatchExistingPersonRequest batchExistingPersonRequest);

    /**
     * 删除人员项目分配
     *
     * @param projectAssignmentId
     * @return
     */
    @ApiOperation(httpMethod = "DELETE", value = "删除人员项目分配")
    @DeleteMapping(value = "/deleteProjectAssignment")
    ResponseData<Boolean> deleteProjectAssignment(@RequestParam(value = "projectAssignmentId") Long projectAssignmentId);

    /**
     * 项目组织、项目管理页面查看项目组织下的人员信息表格
     *
     * @param offset
     * @param pageSize
     * @param projectId
     * @param projectOrganizationId
     * @param lastName
     * @param userName
     * @param mobile
     * @param containProjectOrganizationChildren
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "项目组织、项目管理页面查看项目组织下的人员信息表格")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "offset", value = "页码", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页行数", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "projectOrganizationId", value = "项目组织id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "lastName", value = "姓名", dataType = "String", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "userName", value = "登录名", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "employeeNum", value = "工号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "mobile", value = "手机号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "containProjectOrganizationChildren", value = "是否包含下级", dataType = "boolean", dataTypeClass = Boolean.class),
    })
    @GetMapping(value = "/queryProjectAssignmentPersonInfoPagination")
    ResponseData<PaginationData<ProjectAssignmentResponse>> getQueryProjectAssignmentPersonInfoPagination(@RequestParam("offset") Long offset,
                                                                                                          @RequestParam("pageSize") Long pageSize,
                                                                                                          @RequestParam("projectId") Long projectId,
                                                                                                          @RequestParam(value = "projectOrganizationId", required = false) Long projectOrganizationId,
                                                                                                          @RequestParam(value = "lastName", required = false) String lastName,
                                                                                                          @RequestParam(value = "userName", required = false) String userName,
                                                                                                          @RequestParam(value = "employeeNum", required = false) String employeeNum,
                                                                                                          @RequestParam(value = "mobile", required = false) String mobile,
                                                                                                          @RequestParam(value = "containProjectOrganizationChildren", required = false) boolean containProjectOrganizationChildren);



    /**
     * 项目组织、项目管理页面查看项目组织下的人员信息表格
     *
     * @param projectId
     * @param projectOrganizationId
     * @param lastName
     * @param userName
     * @param mobile
     * @param containProjectOrganizationChildren
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "项目组织、项目管理页面查看项目组织下的人员信息表格")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "projectOrganizationId", value = "项目组织id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "lastName", value = "姓名", dataType = "String", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "userName", value = "登录名", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "employeeNum", value = "工号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "mobile", value = "手机号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "containProjectOrganizationChildren", value = "是否包含下级", dataType = "boolean", dataTypeClass = Boolean.class),
    })
    @GetMapping(value = "/queryProjectAssignmentPersonInfoForMobile")
    ResponseData<ProjectAssignmentForMobileResp> getQueryProjectAssignmentPersonInfo(@RequestParam("projectId") Long projectId,
                                                                                               @RequestParam(value = "projectOrganizationId", required = false) Long projectOrganizationId,
                                                                                               @RequestParam(value = "lastName", required = false) String lastName,
                                                                                               @RequestParam(value = "userName", required = false) String userName,
                                                                                               @RequestParam(value = "employeeNum", required = false) String employeeNum,
                                                                                               @RequestParam(value = "mobile", required = false) String mobile,
                                                                                               @RequestParam(value = "containProjectOrganizationChildren", required = false) boolean containProjectOrganizationChildren);

    /**
     * 用户管理界面根据项目id获取被分配的人员id
     *
     * @param projectId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "用户管理界面根据项目id获取被分配的人员id")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long", dataTypeClass = Long.class),
    })
    @GetMapping(value = "/queryPersonIdsByProjectId")
    ResponseData<List<Long>> getQueryPersonIdsByProjectId(@RequestParam("projectId") Long projectId);

    /**
     * 用户管理界面根据人员id数组获取项目名称拼接
     *
     * @param personIds
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "用户管理界面根据人员id数组获取项目名称拼接")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "personIds", value = "人员id数组", dataType = "List", dataTypeClass = List.class),
    })
    @GetMapping(value = "/queryProjectNamesByPersonIds")
    ResponseData<Map<Long, String>> getQueryProjectNamesByPersonIds(@RequestParam("personIds") List<Long> personIds);

    /**
     * 根据人员ids获取项目分配信息
     *
     * @param personIds
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "根据人员ids获取项目分配信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "personIds", value = "人员id", dataType = "List<Long>", dataTypeClass = ArrayList.class),
    })
    @GetMapping(value = "/queryProjectAssignmentsByPersonIds")
    ResponseData<List<ProjectAssignmentResponse>> getQueryProjectAssignmentsByPersonIds(@RequestParam("personIds") List<Long> personIds);

    /**
     * 根据人员id获取项目分配信息
     *
     * @param personId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "根据人员id获取项目分配信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "personId", value = "人员id", dataType = "Long", dataTypeClass = Long.class),
    })
    @GetMapping(value = "/queryProjectAssignmentsByPersonId")
    ResponseData<List<ProjectAssignmentResponse>> getQueryProjectAssignmentsByPersonId(@RequestParam(value = "personId") Long personId);
    /**
     * 根据人员id删除项目分配信息
     *
     * @param personId
     * @return
     */
    @ApiOperation(httpMethod = "DELETE", value = "根据人员id和项目id删除项目分配信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "personId", value = "人员id", dataType = "Long", dataTypeClass = Long.class),

    })
    @DeleteMapping(value = "/deleteProjectAssignmentsByPersonId")
    ResponseData<Boolean> deleteProjectAssignmentsByPersonId(@RequestParam("personId") Long personId);
    /**
     * 根据人员id删除项目分配信息
     *
     * @param personId，projectId
     * @return
     */
    @ApiOperation(httpMethod = "DELETE", value = "根据人员id和项目id删除项目分配信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "personId", value = "人员id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long", dataTypeClass = Long.class),
    })
    @DeleteMapping(value = "/deleteProjectAssignmentsByPersonIdAndProject")
    ResponseData<Boolean> deleteProjectAssignmentsByPersonIdAndProjectId(@RequestParam("personId") Long personId,@RequestParam("projectId") Long projectId);

    /**
     * 根据项目组织id判断是否存在分配信息
     *
     * @param projectOrganizationId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "根据项目组织id判断是否存在分配信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectOrganizationId", value = "项目组织id", dataType = "Long", dataTypeClass = Long.class),
    })
    @GetMapping(value = "/validateProjectOrganizationHasAssignment")
    ResponseData<Boolean> getValidateProjectOrganizationHasAssignment(@RequestParam("projectOrganizationId") Long projectOrganizationId);

    /**
     * 根据当前项目组织id获取当前层级下的人员
     *
     * @param projectOrganizationId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "根据当前项目组织id获取当前层级下的人员")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectOrganizationId", value = "项目组织id", dataType = "Long", dataTypeClass = Long.class)
    })
    @GetMapping(value = "/queryPersonSimpleByCurrentProjectOrganizationId")
    ResponseData<List<Long>> getQueryPersonSimpleByCurrentProjectOrganizationId(@RequestParam("projectOrganizationId") Long projectOrganizationId);

    /**
     * 根据人员id获取项目分配信息
     *
     * @param personId 人员id
     * @return ResponseData<List<ProjectAssignmentResponse>>
     */
    @ApiOperation(httpMethod = "GET", value = "根据人员id获取项目分配信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "personId", value = "人员id", dataType = "Long", dataTypeClass = Long.class),
    })
    @GetMapping(value = "/queryProjectAssignmentsByPersonIdNoToken")
    ResponseData<List<ProjectAssignmentResponse>> getQueryProjectAssignmentsByPersonIdNoToken(@RequestParam("personId") Long personId);


    /**
     * 查询 项目分配（项目/人员/项目组织三者关系） 列表
     *
     * @param projectAssignmentListQueryRequest 列表查询条件
     * @return ResponseData<List<ProjectResp>>
     */
    @ApiOperation(httpMethod = "POST", value = "查询 项目分配（项目/人员/项目组织三者关系） 列表")
    @PostMapping(value = "/getProjectAssignmentList")
    ResponseData<List<ProjectAssignmentResp>> getProjectAssignmentList(@Valid @RequestBody ProjectAssignmentListQueryRequest projectAssignmentListQueryRequest);

    /**
     * 查询 项目分配（项目/人员/项目组织三者关系） 列表
     *
     * @param projectAssignmentListQueryRequest 列表查询条件
     * @return ResponseData<List<ProjectResp>>
     */
    @ApiOperation(httpMethod = "POST", value = "查询 项目分配（项目/人员/项目组织三者关系） 列表")
    @PostMapping(value = "/getProjectAssignmentListWithoutToken")
    ResponseData<List<ProjectAssignmentResp>> getProjectAssignmentListWithoutToken(@Valid @RequestBody ProjectAssignmentListQueryRequest projectAssignmentListQueryRequest);
}
